#ifndef WYPLCCOM_H
#define WYPLCCOM_H

#include <QObject>
#include <qtcpserver.h>
#include <qtcpsocket.h>

#include "_Interface/_global_datastruct.h"
#include "Package/simpletcpserverdll_global.h"
#include "Package/simpletcpsocketdll_global.h"

#define StateMachine_ForceSensor 0
#define StateMachine_SpindleStatus_ON 1
#define StateMachine_SpindleStatus_OFF 2
#define StateMachine_SpindleSpeed 3
#define StateMachine_SpindleDir_RIGHT 4
#define StateMachine_SpindleDir_Left 5

class WyPLCCom{
private:
    int        toWyPLCSocket;
    QByteArray RecvRawWyPLCData;
    ST_WyFswData mWyFswData;

    short StateMachine;
    int   AskDelay;
public:
    WyPLCCom();
    ~WyPLCCom();

public:
    short PlcConnect(QString ip, int port);
    short ReadForceSensorData(double &Data);
    short SetSpindleStatusSetting(bool status);
    short SetSpindleSpeedSetting(int Data);
    short SetSpindleSpeedDir(bool dir);

private:
    short PLCRecvDataDeal();
    short toPLCLoopRun();
};

#endif // WYPLCCOM_H
